{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import h5py\n",
    "import matplotlib.pyplot as plt\n",
    "from LungSegmentation import lung_segmentation_scan "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "LIDC_vol_file = h5py.File('/data_4t/Kaggle/backup/lidc/vol.hdf5', 'r')\n",
    "vol = LIDC_vol_file['LIDC-IDRI-0001_01'][:]\n",
    "vol = lung_segmentation_scan(vol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAYAAACVSwr3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADLJJREFUeJzt3E+oXOd9h/HnmytbDnVKpNoVQhK1Cncjh9YJQjU4FDfg\nWnVC5JVRIUULgTYqOLQQpAZasnO7CFl5IRLTC/kjBEmw8KJFUQzZFMtSbDeWbEU3sYUkZKshhCRd\nKJXy62Jep2O9djRXmnPv3PT5wGXOvHOO5idsPz5zZuamqpCkcR9Y6QEkzR7DIKljGCR1DIOkjmGQ\n1DEMkjqDhSHJziRnkywmOTDU80iavgzxOYYkc8APgUeAi8CLwF9X1ZmpP5mkqRvqjGEHsFhVP66q\nXwGHgV0DPZekKVsz0J+7Cbgwdv8i8Gfvt3MSP34pDe8nVXXvJDsOFYabSrIP2LdSzy/9P3R+0h2H\nCsMlYMvY/c1t7Teq6hBwCDxjkGbNUNcYXgTmk2xNciewGzg60HNJmrJBzhiq6lqSvwX+HZgDnqmq\n00M8l6TpG+TtyiUP4UsJaTmcqqrtk+zoJx8ldQyDpI5hkNQxDJI6hkFSxzBI6hgGSR3DIKljGCR1\nDIOkjmGQ1DEMkjqGQVLHMEjqGAZJHcMgqWMYJHUMg6SOYZDUMQ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gHubtt3AC8AD87anGPz/h3wdeC5Wf1n\n357/TeCeG9amNutKnzHsABar6sdV9SvgMKOvba+Yqvoe8NMblmfuK+ZVdbmqvt+2fwG8xuhbrDM1\na438st29o/3UrM0JkGQz8Engy2PLMzfnbzG1WVc6DBN9RXsG3NZXzIeW5D7go4z+bzxzs7bT85cZ\nfdHuWFXN5JzAl4DPAb8eW5vFOWGAX4UwbtKvXaupWvpXzIeU5G7gm8Bnq+rn7TstwOzMWqPvyjyQ\n5MOMvnfzkRseX/E5k3wKuFJVp5I8/F77zMKcY6b+qxDGrfQZw2r5ivZMfsU8yR2MovC1qvrWLM8K\nUFU/A55n9Cv/Zm3Oh4BPJ3mT0UvaTyT56gzOCQz/qxBWOgwvAvNJtia5k9Hvijy6wjO9l5n7inlG\npwZfAV6rqi/O6qxJ7m1nCiT5IPAI8PqszVlVB6tqc1Xdx+jfw+9W1WdmbU5Ypl+FsFxXUX/L1dXH\nGF1R/xHw+RmY5xvAZeB/GL0W2wv8AaNfeHsO+A6wfmz/z7fZzwJ/tYxzfpzR68z/BF5uP4/N2qzA\nnwAvtTlfBf6xrc/UnDfM/DD/967EzM3J6F28V9rP6Xf+u5nmrH7yUVJnpV9KSJpBhkFSxzBI6hgG\nSR3DIKljGCR1DIOkjmGQ1PlfqZJy6H2ax1kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fa5150b6160>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(vol[:,:,40],cmap='gray')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vol.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
